package com.mhstay.portlet;

import java.io.IOException;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;

import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.service.ServiceContextFactory;
import com.liferay.util.bridges.mvc.MVCPortlet;
import com.mhstay.slayer.service.HouseLocalServiceUtil;

public class HostPortlet extends MVCPortlet {

	public void saveHome(ActionRequest actionRequest,
			ActionResponse actionResponse) throws IOException, PortletException {

		long houseId = ParamUtil.getLong(actionRequest, "houseId");
		int houseType = ParamUtil.getInteger(actionRequest, "houseType");
		String catchPhrase = ParamUtil.getString(actionRequest, "catchPhrase");
		String houseFamilyDesc = ParamUtil.getString(actionRequest, "houseFamilyDesc");
		String houseRules = ParamUtil.getString(actionRequest, "houseRules");
		String accomodates = ParamUtil.getString(actionRequest, "accomodates");
		
		ServiceContext serviceContext = null;
		try {
			serviceContext = ServiceContextFactory.getInstance(actionRequest);
		} catch (PortalException e) {
			e.printStackTrace();
		} catch (SystemException e) {
			e.printStackTrace();
		}
		
		HouseLocalServiceUtil.updateHomeStay(houseId, houseType, catchPhrase, houseFamilyDesc, houseRules, accomodates, serviceContext);
	}
}